package com.qiantu.phone.ui.activity;

import android.content.Intent;
import android.view.View;

import com.qiantu.phone.R;
import com.qiantu.phone.app.AppActivity;

public class AddConditionActivity extends AppActivity {

    //创建场景或者联动入口
    public static final int TYPE_SCENE_LINKAGE = 0;
    //创建联动条件入口
    public static final int TYPE_LINKAGE = 1;

    private View addScene;
    private View addTiming;
    private View addEnvironment;
    private View addDeviceStateChange;
    private int type;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_add_condition;
    }

    @Override
    protected void initView() {
        View addSceneLayout = findViewById(R.id.add_scene_layout);
        View tvSceneLabel = findViewById(R.id.tv_scene_label);
        View tvLinkageLabel = findViewById(R.id.tv_linkage_label);
        addScene = findViewById(R.id.add_scene);
        addTiming = findViewById(R.id.add_timing);
        addEnvironment =  findViewById(R.id.add_environment);
        addDeviceStateChange = findViewById(R.id.add_device_state_change);
        type = getInt("type");
        switch (type){
            case TYPE_SCENE_LINKAGE:
                tvSceneLabel.setVisibility(View.VISIBLE);
                tvLinkageLabel.setVisibility(View.VISIBLE);
                addSceneLayout.setVisibility(View.VISIBLE);
                setTitle(R.string.intelligent_trigger_condition);
                break;
            case TYPE_LINKAGE:
                tvSceneLabel.setVisibility(View.GONE);
                tvLinkageLabel.setVisibility(View.GONE);
                addSceneLayout.setVisibility(View.GONE);
                setTitle(R.string.add_condition);
                break;
        }
        setOnClickListener(addScene, addTiming, addEnvironment, addDeviceStateChange);
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View view) {
        if (view == addScene){
            startActivity(EditSceneActivityNew.class);
        }else if (view == addTiming){
            Intent intent = new Intent(this, EditTimeActivity.class);
            startActivity(intent);
        }else if (view == addEnvironment){
            Intent intent = new Intent(this, EnvironmentActivity.class);
            startActivity(intent);
        }else if (view == addDeviceStateChange){
            Intent intent = new Intent(this, SelectDeviceActivity.class);
            intent.putExtra("type", SelectDeviceActivity.TYPE_SELECT_TRIGGER_DEVICE);
            startActivity(intent);
        }
    }
}